package uml.construct.prototype.deepclone;

import java.io.*;

/**
 * 深克隆--实体-周报<br>
 * on 2022/12/30 21:15
 */
public class MonthlyLog implements Serializable, DeepClone<MonthlyLog> {
    private String name;
    private String date;
    private String desc;
    private Attachment attachment;


    public MonthlyLog(String name, String date, String desc) {
        this.name = name;
        this.date = date;
        this.desc = desc;
    }

    public String getName() {
        return name;
    }

    public String getDate() {
        return date;
    }

    public String getDesc() {
        return desc;
    }

    public Attachment getAttachment() {
        return attachment;
    }

    public void setAttachment(Attachment attachment) {
        this.attachment = attachment;
    }

    @Override
    public MonthlyLog deeplyClone() throws IOException, ClassNotFoundException {
        ByteArrayOutputStream bao = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(bao);
        oos.writeObject(this);
        ByteArrayInputStream bis = new ByteArrayInputStream(bao.toByteArray());
        ObjectInputStream ois = new ObjectInputStream(bis);
        Object deeplyClonedObject = ois.readObject();
        return (MonthlyLog) deeplyClonedObject;
    }
}
